<template>
  <div class="content-block block-1">
    <div class="info-head">{{ title }}</div>
    <div class="info-content padding-bottom">
      <v-chart :option="chartOption" style="width: 100%;height:300px;"></v-chart>
    </div>
  </div>
</template>

<script>
export default {
  name: 'grid-item-two',
  props: {
    title: String,
    data: {
      type: Array,
      default () {
        return []
      }
    }
  },
  computed: {
    months () {
      return this.data.map(v => v.name)
    },
    thisPeriods () {
      return this.data.map(v => v.usage.thisPeriod)
    },
    samePeriods () {
      return this.data.map(v => v.usage.samePeriod)
    },
    chartOption () {
      return {
        color: ['#50fdfc', '#e6b00e'],
        legend: {
          left: 'center',
          top: 'bottom',
          textStyle: {
            color: '#6b92b5',
          }
        },
        tooltip: {
          trigger: 'item'
        },
        grid: {
          left: '5%',
          right: '5%'
        },
        xAxis: {
          type: 'category',
          data: this.months,
          axisLine: {
            lineStyle: {
              color: '#2b7ed6',
            }
          },
          axisLabel: {
            color: '#6b92b5',
          },
        },
        yAxis: {
          type: 'value',
          name: '万吨',
          axisLine: {
            lineStyle: {
              color: '#2b7ed6',
            }
          },
          splitLine: {
            lineStyle: {
              color: '#024287',
            }
          },
          axisLabel: {
            color: '#6b92b5',
          },
        },
        series: [
          {
            type: 'bar',
            name: '本期',
            data: this.thisPeriods,
          },
          {
            type: 'bar',
            name: '同期',
            data: this.samePeriods,
          }
        ]
      }
    },
  },
}
</script>

<style scoped>

</style>
